//
//  QQOnlineViewController.m
//  jizhiyunduan
//
//  Created by 鞠超 on 16/6/29.
//  Copyright © 2016年 JC. All rights reserved.
//

#import "QQOnlineViewController.h"

@interface QQOnlineViewController () <UITableViewDelegate, UITableViewDataSource>

@property (nonatomic, strong) UITableView * tableView;

@end

@implementation QQOnlineViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self p_navi];
    
    [self p_setupView];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - navi
- (void)p_navi
{
    _lblTitle.text = [NSString stringWithFormat:@"QQ客服列表"];
    _lblTitle.font = [UIFont systemFontOfSize:20];
    
    _btnRight.hidden = YES;
    
    [self addLeftButton:@"fanhui@2x.png"];
}

//左返回
- (void)clickLeftButton:(UIButton *)sender
{
    [self.navigationController popViewControllerAnimated:YES];
}

//隐藏tabbar
-(void)viewWillAppear:(BOOL)animated
{
    [(AppDelegate *)[[UIApplication sharedApplication] delegate] hiddenTabBar];
}

#pragma mark - 布局
- (void)p_setupView
{
    self.view.backgroundColor = [UIColor groupTableViewBackgroundColor];
    
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 64, SCREEN_WIDTH, SCREEN_HEIGHT - 64) style:(UITableViewStylePlain)];
    
    self.tableView.backgroundColor = [UIColor groupTableViewBackgroundColor];
    self.tableView.dataSource = self;
    self.tableView.delegate = self;
    self.tableView.tableFooterView = [[UIView alloc] init];
    
    [self.view addSubview:self.tableView];
}

#pragma mark - tableview代理
- (NSInteger )numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger )tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 5;
}

- (CGFloat )tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 50;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell * cell = [[UITableViewCell alloc] init];
    
    UIImageView * image = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 30, 30)];
    image.layer.cornerRadius = 15;
    [cell addSubview:image];
    
    UILabel * name = [[UILabel alloc] initWithFrame:CGRectMake(50, 12.5, SCREEN_WIDTH - 60, 25)];
    [cell addSubview:name];
    
    switch (indexPath.row)
    {
        case 0:
        {
            image.image = [UIImage imageNamed:@"wangzhankefu1@2x.png"];
            
            name.text = @"网站客服";
        }
            break;
        case 1:
        {
            image.image = [UIImage imageNamed:@"wangzhankefu12@2x.png"];
            
            name.text = @"SEO客服";
        }
            break;
        case 2:
        {
            image.image = [UIImage imageNamed:@"seokefu@2x.png"];
            
            name.text = @"纷享销客客服";
        }
            break;
        case 3:
        {
            image.image = [UIImage imageNamed:@"fenxiangkefu@2x.png"];
            
            name.text = @"APP客服";
        }
            break;
        case 4:
        {
            image.image = [UIImage imageNamed:@"APPkefu@2x.png"];
            
            name.text = @"400客服";
        }
            break;
        default:
            break;
    }
    
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    UIWebView * webView = [[UIWebView alloc] initWithFrame:CGRectZero];
    
    switch (indexPath.row)
    {
        case 0:
        {
            //记得plist文件里面要添加信任列表.
            NSString * string = @"mqq://im/chat?chat_type=wpa&uin=75885146&version=1&src_type=web";
            [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:string]]];
            [self.view addSubview:webView];
        }
            break;
        case 1:
        {
            NSString * string = @"mqq://im/chat?chat_type=wpa&uin=75885146&version=1&src_type=web";
            [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:string]]];
            [self.view addSubview:webView];
        }
            break;
        case 2:
        {
            NSString * string = @"mqq://im/chat?chat_type=wpa&uin=75885146&version=1&src_type=web";
            [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:string]]];
            [self.view addSubview:webView];
        }
            break;
        case 3:
        {
            NSString * string = @"mqq://im/chat?chat_type=wpa&uin=75885146&version=1&src_type=web";
            [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:string]]];
            [self.view addSubview:webView];
        }
            break;
        case 4:
        {
            NSString * string = @"mqq://im/chat?chat_type=wpa&uin=75885146&version=1&src_type=web";
            [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:string]]];
            [self.view addSubview:webView];
        }
            break;
   
        default:
            break;
    }
}






@end
